package com.sm.controller;

import java.util.List;

import com.sm.model.Teacher;
import com.sm.model.VideoCourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sm.model.CourseBean;
import com.sm.service.TeacherService;
import com.sm.service.VideoCourseService;
import com.sm.util.Msg;

@Controller
@RequestMapping("/Course")
public class CourseController {

	@Autowired
	private VideoCourseService videoCourseService;
	
	@Autowired
	private TeacherService teacherService;
	
//	/**
//	 * 查询精品课程
//	 * @return
//	 */
//	@RequestMapping("/selectCourseBoutique")
//	@ResponseBody
//	public Msg selectCourseBoutique() {
//
//		List<VideoCourse> clist = videoCourseService.selectCourseBoutique(1,5).getRows();
//
//		return Msg.success().add("clist", clist);
//	}
	
//	/**
//	 * 查名家讲坛全部
//	 * @return
//	 */
//	@RequestMapping("/selectFamousSpeaker")
//	@ResponseBody
//	public Msg selectFamousSpeaker() {
//		List<CourseBean> clist = videoCourseService.selectFamousSpeaker();
//		return Msg.success().add("clist", clist);
//	}
	
	/**
	 * 查教师信息
	 * @return
	 */
	@RequestMapping("/selectTeacher")
	@ResponseBody
	public Msg selectTeacher() {
		List<Teacher> tlist = teacherService.selectAll();
		return Msg.success().add("tlist", tlist);
	}
	
	/**
	 * 按讲师名查名家讲坛
	 * @param teacherName
	 * @return
	 */
	@RequestMapping("/selectFSByName")
	@ResponseBody
	public Msg selectFamousSpeaker(String teacherName) {
		if(teacherName==null) {
			return Msg.fail().add("msg", "缺少参数");
		}
		List<CourseBean> clist = videoCourseService.selectFSByTeacherName(1,5,teacherName).getRows();
		return Msg.success().add("clist", clist);
	}
	
	/**
	 * 按讲师名查名家讲坛按视频id
	 * @param videoCourseId
	 * @return
	 */
	@RequestMapping("/selectFSByVideoCourseId")
	@ResponseBody
	public Msg selectFSByVideoCourseId(Integer videoCourseId) {	
		if(videoCourseId==null) {
			return Msg.fail().add("msg", "缺少参数");
		}
		
		CourseBean cv = videoCourseService.selectFSByVideoCourseId(videoCourseId);
		return Msg.success().add("cv", cv);
	}
	
}
